//
//  UseFilterCommand.m
//  Cidney
//
//  Created by Chris Karr on 5/12/08.
//  Copyright 2008 Northwestern University. All rights reserved.
//

#import "UseFilterCommand.h"
#import "FilterManager.h"

@implementation UseFilterCommand

- (void) performDefaultImplementation
{
	NSString * filterName = [[self arguments] valueForKey:@"name"];
	
	FilterManager * sharedFilterManager = [FilterManager sharedFilterManager];
	
	if (sharedFilterManager)
	{
		if ([[sharedFilterManager allFilterNames] containsObject:filterName])
			[[FilterManager sharedFilterManager] selectFilterWithTitle:filterName];
		else
		{
			[self setScriptErrorNumber:errAEBadListItem];
			[self setScriptErrorString:[NSString stringWithFormat:@"No such filter '%@'.", filterName]];
		}
	}
}

@end
